# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        黄周云  
# Name:         test04
# Description:  例9.4
# Author:       ASUS
# Date:         2019/3/12
#-------------------------------------------------------------------------------


class CustomException1(Exception):
    pass
class CustomException2(Exception):
    pass
class CustomException3(Exception):
    pass

import random
# 随机抛出前面3个自定义异常
def raiseException():
    n = random.randint(1,3)                            #n为1到3的随机整数
    print("抛出CustomException{}异常".format(n))
    if n == 1:
        raise CustomException1
    elif n == 2:
        raise CustomException2
    else:
        raise CustomException3

try:
    raiseException()
except(CustomException1,CustomException2,CustomException3):        #except子句允许指定多个异常
    print("****执行异常处理程序****")





